// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Graph
{
	public sealed partial class ExploreControls
	{
		[JsonInclude]
		[JsonPropertyName("sample_diversity")]
		public Elastic.Clients.Elasticsearch.Graph.SampleDiversity? SampleDiversity { get; set; }

		[JsonInclude]
		[JsonPropertyName("sample_size")]
		public int? SampleSize { get; set; }

		[JsonInclude]
		[JsonPropertyName("timeout")]
		public Elastic.Clients.Elasticsearch.Duration? Timeout { get; set; }

		[JsonInclude]
		[JsonPropertyName("use_significance")]
		public bool UseSignificance { get; set; }
	}

	public sealed partial class ExploreControlsDescriptor<TDocument> : SerializableDescriptorBase<ExploreControlsDescriptor<TDocument>>
	{
		internal ExploreControlsDescriptor(Action<ExploreControlsDescriptor<TDocument>> configure) => configure.Invoke(this);
		public ExploreControlsDescriptor() : base()
		{
		}

		private Elastic.Clients.Elasticsearch.Graph.SampleDiversity? SampleDiversityValue { get; set; }

		private SampleDiversityDescriptor<TDocument> SampleDiversityDescriptor { get; set; }

		private Action<SampleDiversityDescriptor<TDocument>> SampleDiversityDescriptorAction { get; set; }

		private int? SampleSizeValue { get; set; }

		private Elastic.Clients.Elasticsearch.Duration? TimeoutValue { get; set; }

		private bool UseSignificanceValue { get; set; }

		public ExploreControlsDescriptor<TDocument> SampleDiversity(Elastic.Clients.Elasticsearch.Graph.SampleDiversity? sampleDiversity)
		{
			SampleDiversityDescriptor = null;
			SampleDiversityDescriptorAction = null;
			SampleDiversityValue = sampleDiversity;
			return Self;
		}

		public ExploreControlsDescriptor<TDocument> SampleDiversity(SampleDiversityDescriptor<TDocument> descriptor)
		{
			SampleDiversityValue = null;
			SampleDiversityDescriptorAction = null;
			SampleDiversityDescriptor = descriptor;
			return Self;
		}

		public ExploreControlsDescriptor<TDocument> SampleDiversity(Action<SampleDiversityDescriptor<TDocument>> configure)
		{
			SampleDiversityValue = null;
			SampleDiversityDescriptor = null;
			SampleDiversityDescriptorAction = configure;
			return Self;
		}

		public ExploreControlsDescriptor<TDocument> SampleSize(int? sampleSize)
		{
			SampleSizeValue = sampleSize;
			return Self;
		}

		public ExploreControlsDescriptor<TDocument> Timeout(Elastic.Clients.Elasticsearch.Duration? timeout)
		{
			TimeoutValue = timeout;
			return Self;
		}

		public ExploreControlsDescriptor<TDocument> UseSignificance(bool useSignificance = true)
		{
			UseSignificanceValue = useSignificance;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (SampleDiversityDescriptor is not null)
			{
				writer.WritePropertyName("sample_diversity");
				JsonSerializer.Serialize(writer, SampleDiversityDescriptor, options);
			}
			else if (SampleDiversityDescriptorAction is not null)
			{
				writer.WritePropertyName("sample_diversity");
				JsonSerializer.Serialize(writer, new SampleDiversityDescriptor<TDocument>(SampleDiversityDescriptorAction), options);
			}
			else if (SampleDiversityValue is not null)
			{
				writer.WritePropertyName("sample_diversity");
				JsonSerializer.Serialize(writer, SampleDiversityValue, options);
			}

			if (SampleSizeValue.HasValue)
			{
				writer.WritePropertyName("sample_size");
				writer.WriteNumberValue(SampleSizeValue.Value);
			}

			if (TimeoutValue is not null)
			{
				writer.WritePropertyName("timeout");
				JsonSerializer.Serialize(writer, TimeoutValue, options);
			}

			writer.WritePropertyName("use_significance");
			writer.WriteBooleanValue(UseSignificanceValue);
			writer.WriteEndObject();
		}
	}

	public sealed partial class ExploreControlsDescriptor : SerializableDescriptorBase<ExploreControlsDescriptor>
	{
		internal ExploreControlsDescriptor(Action<ExploreControlsDescriptor> configure) => configure.Invoke(this);
		public ExploreControlsDescriptor() : base()
		{
		}

		private Elastic.Clients.Elasticsearch.Graph.SampleDiversity? SampleDiversityValue { get; set; }

		private SampleDiversityDescriptor SampleDiversityDescriptor { get; set; }

		private Action<SampleDiversityDescriptor> SampleDiversityDescriptorAction { get; set; }

		private int? SampleSizeValue { get; set; }

		private Elastic.Clients.Elasticsearch.Duration? TimeoutValue { get; set; }

		private bool UseSignificanceValue { get; set; }

		public ExploreControlsDescriptor SampleDiversity(Elastic.Clients.Elasticsearch.Graph.SampleDiversity? sampleDiversity)
		{
			SampleDiversityDescriptor = null;
			SampleDiversityDescriptorAction = null;
			SampleDiversityValue = sampleDiversity;
			return Self;
		}

		public ExploreControlsDescriptor SampleDiversity(SampleDiversityDescriptor descriptor)
		{
			SampleDiversityValue = null;
			SampleDiversityDescriptorAction = null;
			SampleDiversityDescriptor = descriptor;
			return Self;
		}

		public ExploreControlsDescriptor SampleDiversity(Action<SampleDiversityDescriptor> configure)
		{
			SampleDiversityValue = null;
			SampleDiversityDescriptor = null;
			SampleDiversityDescriptorAction = configure;
			return Self;
		}

		public ExploreControlsDescriptor SampleSize(int? sampleSize)
		{
			SampleSizeValue = sampleSize;
			return Self;
		}

		public ExploreControlsDescriptor Timeout(Elastic.Clients.Elasticsearch.Duration? timeout)
		{
			TimeoutValue = timeout;
			return Self;
		}

		public ExploreControlsDescriptor UseSignificance(bool useSignificance = true)
		{
			UseSignificanceValue = useSignificance;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (SampleDiversityDescriptor is not null)
			{
				writer.WritePropertyName("sample_diversity");
				JsonSerializer.Serialize(writer, SampleDiversityDescriptor, options);
			}
			else if (SampleDiversityDescriptorAction is not null)
			{
				writer.WritePropertyName("sample_diversity");
				JsonSerializer.Serialize(writer, new SampleDiversityDescriptor(SampleDiversityDescriptorAction), options);
			}
			else if (SampleDiversityValue is not null)
			{
				writer.WritePropertyName("sample_diversity");
				JsonSerializer.Serialize(writer, SampleDiversityValue, options);
			}

			if (SampleSizeValue.HasValue)
			{
				writer.WritePropertyName("sample_size");
				writer.WriteNumberValue(SampleSizeValue.Value);
			}

			if (TimeoutValue is not null)
			{
				writer.WritePropertyName("timeout");
				JsonSerializer.Serialize(writer, TimeoutValue, options);
			}

			writer.WritePropertyName("use_significance");
			writer.WriteBooleanValue(UseSignificanceValue);
			writer.WriteEndObject();
		}
	}
}